package be.kuleuven.mume.arrayAdapters;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TwoLineListItem;
import be.kuleuven.mume.R;
import be.kuleuven.mume.framework.Vraag;

public class VraagArrayAdapter extends ArrayAdapter<Vraag>{
	 
	public VraagArrayAdapter(Context context, List<Vraag> objects) {
		super(context, R.layout.rij_vraag, objects);
	}
 
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
 
		Vraag n = (Vraag) getItem(position);
 
		// if the array item is null, nothing to display, just return null
		if (n == null) {
			return null;
		}
 
		// Pick up the TwoLineListItem defined in the xml file
		TwoLineListItem view;
		if (convertView == null){// || convertView.getId() != R.layout.rij_vraag) {
			// We need the layoutinflater to pick up the view from xml
			LayoutInflater inflater = (LayoutInflater)
							getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = (TwoLineListItem) inflater.inflate(R.layout.rij_vraag, null);
		} else {
			view = (TwoLineListItem) convertView;
		}
		
		view.getText1().setText(n.getSubject());
		view.getText2().setText(n.getText());
 
 
		return view;
	}
}
